<template>
  <div class="edit-popup">
    <popup
      ref="popupRef"
      title="直播间补发奖励"
      :async="true"
      width="550px"
      @confirm="handleSubmit"
      @close="handleClose"
    >
      <el-form
        ref="formRef"
        :model="formData"
        label-width="120px"
      >
        <el-form-item label="直播间ID" prop="room_id" >
          <el-input v-model="formData.room_id" placeholder="请输入直播间ID" />
        </el-form-item>
        <el-alert
            type="warning"
            title="温馨提示：1.仅支持非当天直播间的奖励补发，当日直播间满足条件会自动补发奖励 2.补发会按照当前设置进行补发"
            :closable="false"
            show-icon
        />
      </el-form>
    </popup>
  </div>
</template>
<script lang="ts" setup>
import type { FormInstance } from "element-plus";
import {
  reissue_room,
} from "@/api/consumer";
import Popup from "@/components/popup/index.vue";
const emit = defineEmits(["success", "close"]);
const formRef = shallowRef<FormInstance>();
const popupRef = shallowRef<InstanceType<typeof Popup>>();

const formData = reactive({
  room_id: "",
});

const open = () => {
  popupRef.value?.open();
};

const handleClose = () => {
  emit("close");
};

defineExpose({
  open
});
//提交
const handleSubmit = async () => {
	formData.rank_id = formData.id
  await formRef.value?.validate();
  await reissue_room(formData)
  popupRef.value?.close();
  emit("success");
};
</script>
